<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>警告资源管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

        function preview(sourceType, sourceId) {
            top.$.jBox.open("iframe:${ctx}/templet/eleTemplet/preview?sourceType="+sourceType+"&sourceId=" + sourceId, "<spring:message code='preview'/>", 500, 420, {showScrolling: false});
        }
        function playDefAudio(id) {
        	media = $('#defAudio_'+id)[0]; 
        	var playerId = "defPlayer_"+id;
            if(media.paused) {  
            	console.log("1");
                play(playerId);  
            } else {  
            	console.log("2");

                pause(playerId);  
            }  
        }  
        //播放  
        function play(id) {  
            media.play();  
          /*  var lan = $("#pageLanguage").val();
            if(lan == 'zh'){*/
            	$('#'+id).html('<i class="icon-pause"></i>');
            media.addEventListener('ended', function () {
                $('#'+id).html('<i class="icon-play"></i>');
            }, false);
           /* }else{
            	$('#'+id).html('Pause');  
            }*/

            
        }  
          
        //暂停  
        function pause(id) {  
            media.pause();  
           /* var lan = $("#pageLanguage").val();*/
           /* if(lan == 'zh'){*/
            	$('#'+id).html('<i class="icon-play"></i>');

         /*   }else{*/
            /*	$('#'+id).html('Play');*/
          /*  }*/
        }  
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/source/alarm/eleSourceAlarmGroup/"><spring:message code="alarm.list"/></a></li>
		<shiro:hasPermission name="source:alarm:eleSourceAlarmGroup:edit"><li><a href="${ctx}/source/alarm/eleSourceAlarmGroup/form"><spring:message code="alarm.add"/></a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="eleSourceAlarmGroup" action="${ctx}/source/alarm/eleSourceAlarmGroup/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="pageLanguage" name="pageLanguage" type="hidden" value="${language}"/>
		
		<ul class="ul-form">
			<li><label><spring:message code="common.dname"/>：</label>
				<form:input path="name" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.Query'/>"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed" >
		<thead>
			<tr>
				<th><spring:message code="common.dname"/></th>
				<th><spring:message code="alarm.default.audio"/></th>
				<th><spring:message code='common.update_time'/></th>
				<th><spring:message code='common.creater'/></th>

				<th><spring:message code='common.operation'/></th>
				<th><spring:message code='common.remarks'/></th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="eleSourceAlarmGroup">
			<tr>
				<td><a href="${ctx}/source/alarm/eleSourceAlarmGroup/form?id=${eleSourceAlarmGroup.id}">
					${eleSourceAlarmGroup.name}
				</a></td>
				<td>
					<audio id="defAudio_${eleSourceAlarmGroup.id}" src="${eleSourceAlarmGroup.defaudio}" hidden="true"></audio>
					<c:if test="${not empty eleSourceAlarmGroup.defaudio}">
						<%--<c:if test="${language == 'zh'}">--%>
							<a href="javascript:void(0);" onclick="playDefAudio('${eleSourceAlarmGroup.id}');" id="defPlayer_${eleSourceAlarmGroup.id}"><i class="icon-play"></i></a>
						<%--</c:if>--%>
						<%--<c:if test="${language == 'en'}">
							<a href="javascript:void(0);" onclick="playDefAudio('${eleSourceAlarmGroup.id}');" id="defPlayer_${eleSourceAlarmGroup.id}">Play</a>				
						</c:if>--%>
					</c:if>
				
				</td>
				<td>
				
					<fmt:formatDate value="${eleSourceAlarmGroup.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${eleSourceAlarmGroup.createBy.name}
				</td>

					<td>
						<shiro:hasPermission name="source:alarm:eleSourceAlarmGroup:edit">
							<a href="${ctx}/source/alarm/eleSourceAlarmGroup/form?id=${eleSourceAlarmGroup.id}"><spring:message code="common.modify"/></a>
							<a href="${ctx}/source/alarm/eleSourceAlarmGroup/delete?id=${eleSourceAlarmGroup.id}" onclick="return confirmx('<spring:message code='tips.delalarm' />', this.href)"><spring:message code='common.delete'/></a>
						</shiro:hasPermission>
						<shiro:hasPermission name="source:alarm:eleSourceAlarmGroup:check">
							<a href="${ctx}/source/alarm/eleSourceAlarmGroup/check?id=${eleSourceAlarmGroup.id}">审核</a>
						</shiro:hasPermission>
						<a href="javascript:void(0);" onclick="preview('alarm','${eleSourceAlarmGroup.id}')">
							<spring:message code="preview"/>
						</a>
					</td>
				<td>
						${eleSourceAlarmGroup.remarks}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>